const express = require('express');
const fs = require('fs');
const path = require('path');

const router = express.Router();
const rootDir = require('../utils/path');

/* course 临时接口 */
router.use('/api/course', (req, res, next) => {
  res.setHeader('Access-Control-Allow-Origin', '*')
  const jsonData = fs.readFileSync(path.join(rootDir, 'mork', 'course.json')).toString();
  res.json(jsonData);
})

/* teacher 临时接口 */
router.use('/api/teacher', (req, res, next) => {
  res.setHeader('Access-Control-Allow-Origin', '*')
  const jsonData = fs.readFileSync(path.join(rootDir, 'mork', 'teacher.json')).toString();
  res.json(jsonData);
})

/* miniList 临时接口 */
router.use('/api/miniList', (req, res, next) => {
  res.setHeader('Access-Control-Allow-Origin', '*')
  const jsonData = fs.readFileSync(path.join(rootDir, 'mork', 'miniList.json')).toString();
  res.json(jsonData);
})

/* miniDetail 临时接口 */
router.use('/api/miniDetail', (req, res, next) => {
  res.setHeader('Access-Control-Allow-Origin', '*')
  const jsonData = fs.readFileSync(path.join(rootDir, 'mork', 'miniDetail.json')).toString();
  res.json(jsonData);
})


module.exports = router;
